package com.utils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result GlobalExceptionHandler(Exception e){
        if(e instanceof UserException){
            return new Result(((UserException) e).getCode(),((UserException) e).getMsg(),null);
        }else{
            return new Result(10002,"系统内部错误",null);
        }
    }
}
